// 正确的导入方式
import { createRouter, createWebHistory } from 'vue-router';
/* Layout */
import Layout from '@/layout'

const routes = [  
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '',  // 将路径设置为空字符串，这样就会作为默认页面
        component: () => import('../views/UserLogin.vue'),
        name: 'login'
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: 'location',
        component: () => import('../views/User/location/location.vue'),
        name:'location'
      },
      {
        path: 'addlocation',
        component: () => import('../views/User/location/AddLocation.vue'),
        props: true,
        name: 'AddLocation',
      },
      {
        path: '/locationInfo/:placeId', 
        component: () => import('../views/User/location/LocationInfo.vue'),
        props: true,
        name: 'PlaceDetail',
      },      
      {
        path: 'trans',
        component: () => import('../views/User/PictureInfo/PictureTrans.vue')
      },
      {
        path: 'geneDes',
        component: () => import('../views/User/PictureInfo/geneDes.vue'),
        name:'geneDes'
      },
      {
        path: 'addmoodDes',
        component: () => import('../views/User/PictureInfo/addDes.vue'),
        name:'DescriptionCreate'
      },     
      {
        path: 'addjournal/:placeId',  // 注意这里添加了 :placeId 参数
        component: () => import('../views/User/Journal/AddJournal.vue'),
        name: 'CreateJournal',
        props: true,  // 确保路由参数被作为 props 传递
      }, 
      {
        path: 'journaldetail/:diaryId', 
        component: () => import('../views/User/Journal/DiaryDetail.vue'),
        name: 'DiaryDetail',
        props: true,  // 确保路由参数被作为 props 传递
      },      
      {
        path: 'overview',
        component: () => import('../views/User/Journal/overview.vue'),
        name: 'overview'
      },
      {
        path: 'MoodJar', 
        component: () => import('../views/User/MoodJar.vue'),
        name: 'MoodJar',
        props: true,  
      }, 
      {
        path: 'register',
        component: () => import('../views/User/register.vue'),
        props: true,
        name: 'UserRegister',
      },
      {
        path: 'userInfo',
        component: () => import('../views/User/UserInfo.vue'),
        props: true,
        name: 'UserInfo',
      },
    ]
  }
]

// 创建路由器实例
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router;
